package rmi;

import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import dto.*;

public class MainServer extends RmiStarter {

	public MainServer() {
		super(MainServer.class);
	}
	
	@Override
    public void doCustomRmiHandling() {
		try {
			RemoteObject remoteObject = new RemoteObject();
			Registry registry = LocateRegistry.createRegistry(1099);
			registry.bind("//localhost/REG", remoteObject);
			System.out.println("Remote Object Bound.");

		}
		catch (Exception e) {
			
			System.err.println("Remote Object Exception");
			e.printStackTrace();
		}

    }

    public static void main(String[] args) throws RemoteException {
        new MainServer();
       RemoteObject remoteObject = new RemoteObject();
       remoteObject.enviar();
       ViajeDTO v=new ViajeDTO();
       v.setIdViaje(2);
        remoteObject.recibir(v);      
    }
    
}
